package com.hyt.it.ogt.kq.service.gov.feign.cloudefile;

import com.hyt.common.apiInfor.ApiResponse;
import com.hyt.common.utils.exception.RemoteRequestExcepton;
import com.hyt.model.cloudefile.apiparams.FileRecodeParam;
import com.hyt.model.cloudefile.apiparams.PushTaskParam;
import com.hyt.model.cloudefile.entity.CloudeFileProjectRecord;

import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;

import org.springframework.stereotype.Component;

/**
 * feign客户端熔断器
 */
@Component
@Slf4j
public class CloudFileClientHystrix implements FallbackFactory<CloudFileClient> {

    @Override
    public CloudFileClient create(Throwable throwable) {
        log.error("# PushTaskClientHystrix Hystrix message ", throwable);

        return new CloudFileClient() {
            @Override
            public ApiResponse<Boolean> pushTask(PushTaskParam pushTaskParam) {
                log.error("#调用失败，进入熔断");
                throw new RemoteRequestExcepton("调用失败");
            }

            @Override
            public ApiResponse<CloudeFileProjectRecord> queryLastFileRecode(FileRecodeParam fileRecodeParam) {
                log.error("#调用失败，进入熔断");
                throw new RemoteRequestExcepton("无法获取导入记录信息！");
            }

            @Override
            public ApiResponse<Boolean> generateExaminee(String examineeInfoId) {
                log.error("#调用失败，进入熔断");
                throw new RemoteRequestExcepton("无法生成考生准考证！");
            }

            @Override
            public ApiResponse<Boolean> generateTimes(String examineeTimeId) {
                log.error("#调用失败，进入熔断");
                throw new RemoteRequestExcepton("无法生成批次准考证！");
            }

            @Override
            public ApiResponse<String> waterMark(String pdfUrl, String waterText) {
                log.error("#调用失败，进入熔断");
                throw new RemoteRequestExcepton("PDF添加水印失败！");
            }
        };
    }
}
